package com.junl.apps.controller;

import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.junl.apps.service.imageupload.IUploadImg;

@Controller
@RequestMapping(value="/uploadImage")
public class UploadImageAction {
	
	@Autowired
	private IUploadImg uploadImgService;
	
	
	/**
	 * 	图片上传  请求地址：请求地址：http://192.168.1.9:8080/Apps/uploadImage/uploadImage.do
	 * 	参数 ： file  				上传的图片     必填
	 *  	  waterMarkStr		 文字水印        必填
	 *  返回 ：  imageServerPath    图片路径
	 */
	@RequestMapping(value="/uploadImage.do")
	public void uploadImage(@RequestParam("file") CommonsMultipartFile file,@RequestParam("waterMarkStr") String waterMarkStr,HttpServletResponse response)
	{
		try {
			String imageServerPath = uploadImgService.uploadImage(file,waterMarkStr);
			response.getWriter().write(imageServerPath);
			response.getWriter().flush();
			response.getWriter().close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
